import { axios } from "@/utils/request";
import { ITableResPage, ResPage } from "@/utils/types/table.ts";

// 字典查询
export function fetchDictOpts(dictname: string) {
  return axios({
    url: `/common/getEnumList/${dictname}`,
    method: "get",
  });
}
// 列表查询
export function fetchTabelData<T, S>(
  params: T,
  url: string,
): Promise<ITableResPage<S>> {
  return axios({
    url,
    params,
    method: "get",
  });
}

/**
 * 新增数据
 * @param url
 * @param data
 */
export function addRow<D>(
  url: string,
  data: D,
  method?: "post" | "put",
): Promise<ResPage> {
  return axios({
    url,
    method: method || "post",
    data,
  });
}

// 删除
export function delRow(url: string, method: string) {
  return axios({
    url,
    method,
  });
}
